package ai.plantdata.Structural.mode.Composite.test;

import ai.plantdata.Structural.mode.Composite.entity.Employee;

/**
 * @Author: WangHui
 * @Date: 2020/12/21 13:42
 * @Description:
 */
public class CompositePatternDemo {
    public static void main(String[] args) {
        Employee CEO = new Employee("John", "CEO", 30000);
        Employee headSales = new Employee("Robert", "Head Sales", 20000);
        Employee headMarketing = new Employee("Michel", "Head Marketing", 20000);

        Employee clerk1 = new Employee("Laura", "Marking", 10000);
        Employee clerk2 = new Employee("Bob", "Marking", 10000);

        Employee salesExecutive1 = new Employee("Richard", "Sales", 10000);
        Employee salesExecutive2 = new Employee("Rob", "Sales", 10000);

        CEO.add(headSales);
        CEO.add(headMarketing);

        headMarketing.add(salesExecutive1);
        headMarketing.add(salesExecutive2);

        headMarketing.add(clerk1);
        headMarketing.add(clerk2);

        for (Employee subordinate : CEO.getSubordinates()) {
            System.out.println("subordinate = " + subordinate);
            for (Employee subordinateSubordinate : subordinate.getSubordinates()) {
                System.out.println("subordinateSubordinate = " + subordinateSubordinate);
            }
        }
    }
}
